package com.bw.broker.controller;

import com.bw.broker.service.TbUserService;
import com.bw.result.ResultVo;
import com.bw.vo.IdVo;
import com.bw.vo.TbUserSearchVo;
import com.bw.vo.TbUserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: search-house
 * @ClassName TbUserController
 * @description:
 * @author:
 * @create: 2023-11-16 10:40
 * @Version 1.0
 **/
@RestController
@RequestMapping("/user")
@Api(tags = "用户后台管理")
public class TbUserController {


    @Autowired
    private TbUserService tbUserService;




    /** @Author 李博帅
     * @Description //TODO  分页+模糊查询
     * @Date 10:57 2023/11/16
     * @param tbUserSearchVo
     * @return com.bw.result.ResultVo
     **/
    @PostMapping("/listBySearchVo")
    @ApiOperation("用户列表")
    public ResultVo listBySearchVo(@RequestBody TbUserSearchVo tbUserSearchVo){
        return tbUserService.listBySearchVo(tbUserSearchVo);
    }



    /** @Author 李博帅
     * @Description //TODO  逻辑删除
     * @Date 10:59 2023/11/16
     * @param idVo
     * @return com.bw.result.ResultVo
     **/
    @PostMapping("/delete")
    @ApiOperation("用户删除")
    public ResultVo delete(@RequestBody IdVo idVo){
        return tbUserService.delete(idVo);
    }



    /**
     *  添加
     * @Author 李博帅
     * @Description //TODO
     * @Date 11:05 2023/11/16
     * @param tbUserVo
     * @return com.bw.result.ResultVo
     **/
    @PostMapping("/add")
    @ApiOperation("用户添加")
    public ResultVo add(@RequestBody TbUserVo tbUserVo){
        return tbUserService.add(tbUserVo);
    }


    /** @Author 李博帅
     * @Description //TODO 修改
     * @Date 11:05 2023/11/16
     * @param tbUserVo
     * @return com.bw.result.ResultVo
     **/
    @PostMapping("/修改")
    @ApiOperation("用户修改")
    public ResultVo updateByVo(@RequestBody TbUserVo tbUserVo){
        return tbUserService.updateByVo(tbUserVo);
    }
}
